package org.example.controller;

import jakarta.annotation.Resource;
import org.example.service.TextToSpeechService;
import org.springframework.http.HttpStatus;
import org.springframework.http.ResponseEntity;
import org.springframework.web.bind.annotation.*;

/**
 * 语音合成控制器
 *
 * @author rjs
 */

@RestController
@RequestMapping("/speech")
public class JacobTestController {

    /**
     * 语音合成服务
     */
    @Resource
    TextToSpeechService textToSpeechService;

    /**
     * 处理文本转语音请求
     *
     * @param text 要转换的文本
     * @return 操作结果
     */
    @PostMapping
    public ResponseEntity<String> textToSpeech(@RequestParam("text") String text) {

        // 调用TextToSpeechService的textToSpeech方法生成语音
        textToSpeechService.textToSpeech(text);

        // 返回成功消息
        return new ResponseEntity<>("语音生成成功", HttpStatus.OK);
    }

}
